package com.lagou.Dao;

import com.lagou.annotion.Autowired;
import com.lagou.annotion.Comppent;
import com.lagou.config.Config;
import com.lagou.pojo.Account;
import com.lagou.util.SqlsssionUtils;
import org.apache.ibatis.session.SqlSession;

/**
 * @Authther: mrwu
 * @date:2021/3/13-03
 * @Description:com.lagou.Dao
 */
@Comppent
public class AccountDaoImpl implements AccountDao{
    @Autowired
    private  SqlsssionUtils sqlsssionUtils;
    private  SqlSession sqlSession;


    public AccountDaoImpl() {
    }

    public SqlSession getSqlSession() {
        sqlSession= sqlsssionUtils.getCurrentSqlsssion();
        return sqlSession;
    }

    @Override
    public Account selectObjByCardNo(String cardNo) {
        sqlSession= sqlsssionUtils.getCurrentSqlsssion();

//        SqlSession sqlSession = new Config().getSqlSession();
//        SqlSession sqlSession = SqlsssionUtils.getInstance().getCurrentSqlsssion();
        Account one = sqlSession.selectOne("com.lagou.Dao.AccountDao.selectObjByCardNo", cardNo);
        return one;
    }

    @Override
    public int updateAccountBycardNo(Account account) {
         sqlSession= sqlsssionUtils.getCurrentSqlsssion();
//        SqlSession sqlSession = SqlsssionUtils.getInstance().getCurrentSqlsssion();
//        SqlSession sqlSession = new Config().getSqlSession();
        int no = sqlSession.update("com.lagou.Dao.AccountDao.updateAccountBycardNo", account);
//        sqlSession.commit();//提交事务
        return no;
    }
}
